Skip to content

Use HTTPS + secure cookies in all deployed environments#89

Merged
lewispb merged 1 commit into
mainfrom
staging-https-url-options
Jun 9, 2026
Merged

Use HTTPS + secure cookies in all deployed environments#89
lewispb merged 1 commit into
mainfrom
staging-https-url-options

Conversation

@lewispb

@lewispb lewispb commented Jun 9, 2026

Copy link
Copy Markdown
Member

Key default_url_options and the session cookie secure flag on Rails.env.local? instead of Rails.env.production?, so deployed non-prod envs (staging) get https + secure cookies instead of unreachable http://host:3000 URLs. Dev/test unchanged.

…duction

default_url_options and the session cookie's secure flag keyed on
Rails.env.production?, so any non-production *deployed* environment (e.g. staging)
generated http://host:3000 URLs and non-secure session cookies. Behind a
TLS-terminating proxy that broke navigation — e.g. the login redirect pointed at
http://app.<host>:3000/session/new, which isn't reachable.

Key on Rails.env.local? instead (matching the gem's existing idiom): development
and test keep http + the local port; every deployed env (production, staging, ...)
gets https with no port and secure cookies.
Copilot AI review requested due to automatic review settings June 9, 2026 14:56
@lewispb lewispb merged commit dd6b531 into main Jun 9, 2026
9 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Upright’s environment-based URL generation and session cookie configuration so that any non-local (i.e., deployed) environment defaults to HTTPS URLs and secure cookies, while keeping local development/test behavior unchanged.

Changes:

  • Switch session cookie secure flag to be enabled in all non-local environments.
  • Switch default_url_options to use HTTPS outside local environments, and keep HTTP + port only for local.
  • Keep existing host/domain behavior intact while removing the “http://…:3000” default from deployed non-prod environments (e.g., staging).

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/upright/engine.rb Enables secure session cookies in all non-local environments.
lib/upright/configuration.rb Makes generated URLs HTTPS by default outside local dev/test, avoiding http://...:3000 in deployed envs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants